<?php
namespace Home\Controller;
use Think\Controller;
class BaseController extends Controller {
    function __construct() {
        parent::__construct();
          //访问过滤
          //获取用户id name
          $user_id = session('user_id');
          $user_name = session('username');
           //获取正在访问的控制器-操作方法
          $newpath = CONTROLLER_NAME.'-'.ACTION_NAME;
          //判断是否登录
          $auth_path = 'User-login,User-logout,User-register';
          if(empty($user_name) && strpos($auth_path, $newpath)===false){
              $this->redirect('User/login');
          }
          
    }
}